package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import JDBC.DatabaseDao;

public class InlinkDao {

	static Connection con = DatabaseDao.getConnection();

	public static String[] getInlinksByUserId(String userId) {
		String[] result = null;
		try {
			String sql = "select inlinks from inlinks where user_id='" + userId + "'";
//			System.out.println(sql);
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			if (rs.next()) {
				String inlinks = rs.getString(1);
				result = inlinks.split("#");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * @author 韩 闻文 total tags
	 * @return
	 */
	public static int getCount() {
		int result = 0;
		try {
			String sql = "select count(*) from inlinks";
			System.out.println(sql);
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			rs.next();
			result = rs.getInt(1);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

}
